<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="list">
        <li>01</li>
        <li>02</li>
        <li>03</li>
        <li>04</li>
    </div>
</body>
<script>
    var liList = document.querySelectorAll(".list li");


    for (var i = 0; i < liList.length; i++) {
        (function (j) {
            var li = liList[j];   // AO{li,j}
            li.onclick = function () {
                debugger;
                console.log(li, j);
            }
        })(i);
    }

    Array.from(liList).forEach((item, index) => {
        item.onclick = function () {
            console.log(item, index);
        }
    })

</script>

</html>